/*******************************************************************************
* COPYRIGHT LIPUJUN TECH CO.,LTD
********************************************************************************
* 文件名称:  mqttMsmgCmd.h
* 功能描述:
* 使用说明:  无
* 文件作者:  LIPUJUN
* 编写日期:  2018/11/28
* 修改历史:
* 修改版本  修改日期       修改人   修改内容
* ------------------------------------------------------------------------------
  01a       2018/11/28       李普军   创建
*******************************************************************************/

/******************************** 头文件保护开头 *****************************/
#ifndef __USER_CORE_H /* 头文件保护 */
#define __USER_CORE_H /* 头文件保护 */

#include "common.h"
#include "msg_core.h"



#define MQTT_REG_HOST_MSG_INIT   0x00
#define MQTT_REG_HOST_MSG_FAIL   0x01
#define MQTT_REG_HOST_MSG_OK     0x02

#define MQTT_CHANNE   0

enum MSG_DATA_SUM
{
    REG_HOST_ACK_SUM = 5,
    DATA_SYNC_START_SUM = 6,
    DATA_SYNC_END_SUM = 7,
    CLEAN_HDISK_SUM = 2,
    FIRMWARE_UPDATE_SUM = 4,
    HB_MSG_ACK_SUM = 2,
    ONOFF_MSG_ACK_SUM = 1,

};//tmp
typedef struct
{
    UINT8  regHostAck;
    //UINT8  regHostRule;
    //UINT8  regCount;
    //UINT8  HBAck;
    UINT32  HBAckTime;
	//改
    UINT32 regTimeout;
    UINT32 regInterval;
    UINT32 HBTimeout;
    UINT32 HBInterval;

    sem_t msgSem;
    sem_t uploadSem;
    sem_t timeSem;
    sem_t upgradeSem;
    pthread_rwlock_t rwlock; 
    pthread_rwlock_t profile_lock;
    pthread_mutex_t  block_mutex; 
    //sem_t rsem;
    
    CHAR serverIp[ARGV_MAX_LEN];
    CHAR devId[ARGV_MAX_LEN];    
    CHAR netName[ARGV_MAX_LEN];
    CHAR ip[ARGV_MAX_LEN];
    CHAR diskSize[ARGV_MAX_LEN];
    UINT16 port;
   
    //UINT32 ftpCnt;
    UINT8 dataSync;
    UINT8 link;
    //UINT8 ftpEnd;
    //UINT8 isDc;
    //UINT8 upgradeEnd;
    UINT8 isUpgrad;

    MSG_DATA_T rData;
    MSG_DATA_T sData;
	
    UINT8 keepIdle;
    UINT8 keepInterval;
    UINT8 keepCount;
    UINT8 ftpChannelNum;
	
	//版本号
    //CHAR firmVer[ARGV_MAX_LEN];
    CHAR oldVer[ARGV_MAX_LEN];
    CHAR curVer[ARGV_MAX_LEN];
    CHAR tmpVer[ARGV_MAX_LEN];
    CHAR appVer[ARGV_MAX_LEN];

   
	//升级包名称
    CHAR oldFilename[ARGV_MAX_LEN];
    CHAR curFilename[ARGV_MAX_LEN];
    CHAR tmpFilename[ARGV_MAX_LEN];
	//配置文件
    CHAR appConfig[ARGV_MAX_LEN];
    CHAR versionConfig[ARGV_MAX_LEN];
    CHAR upgradeDir[ARGV_MAX_LEN];
    CHAR appLogFile[ARGV_MAX_LEN];
    CHAR shLogFile[ARGV_MAX_LEN];   
        
    CHAR baseUploadPath[ARGV_MAX_LEN];
    CHAR uploadLinkPath[ARGV_MAX_LEN];
    CHAR transferPath[ARGV_MAX_LEN];

    INT32 sock; //连接描述符 
  //  UINT32 airLogMaxTimeout;

    UINT32 powerONTime;
    UINT32 oNTimeDuration;   
    UINT32 uploadStartSize;
    UINT32 transferStartSize;
    UINT32 A6StartSize;
    UINT32 loopLogInterval;
    UINT32 block_max_size;
    UINT32 route_min_time;
    UINT32 UplugTimes;
    UINT32 videoSize;
  
    UINT8 consoleLog;
   // UINT8 conFLogInterval;
    UINT8 ftpNoTimeout;  
    UINT8 isHaveFwUpgrade;
    UINT8 poeIsON;
    UINT8 isRtc;
    UINT8 iscoms;
    //UINT8 isBlock;
    UINT8 percent; 
    UINT8 timeChange;      
    UINT8 isUsbCollect; 
    INT32 curGroupID;
    INT32 curBlockID; 
    INT32 speed;   
}AIR_APP_INFO_T;
typedef struct
{
    CMD_TYPE_E  key;
    INT32 (*fun)(CHAR *, UINT32);
    UINT8 desc[0x80];

}MQTT_MSG_PROCESS_CMD_T;
typedef struct
{
    CHAR url[0x400];
    CHAR fileName[0x100];
    CHAR md5[0x100];
    CHAR version[0x100];

}VER_UPDATE_INFO_T;

INT32 user_init(void);
INT32 mqttMsgCmdRun (INT32 type, CHAR *data, UINT32 len);
INT32 mqttMsgReport_task (void *arg);
INT32 dataFileSync_task (void *arg);
INT32 verUpdate_task (void *arg);
int isGroup(void);
#endif /* __USER_CORE_H *//* 头文件保护 */
/******************************** 头文件结束 *********************************/
